package com.cee.service.Impl;


import com.cee.dao.OneTwoTypeMapper;
import com.cee.dto.OneTwoTypeDTO;
import com.cee.dto.OneTypeDTO;
import com.cee.dto.TwoTypeDTO;
import com.cee.model.OneTwoType;
import com.cee.model.TwoType;
import com.cee.service.OneTwoTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Slf4j
@Service
@Transactional
public class OneTwoTypeServiceImpl implements OneTwoTypeService {

    @Autowired
    private OneTwoTypeMapper oneTwoTypeMapper;


    @Override
    public OneTwoType getOneTwoType(OneTwoType oneTwoType) {
        return oneTwoTypeMapper.getOneTwoType(oneTwoType);
    }

    @Override
    public OneTwoTypeDTO getOneTwoTypeByStr(String oneTypeName, String twoTypeName) {
        return oneTwoTypeMapper.getOneTwoTypeByStr(oneTypeName, twoTypeName);
    }

    @Override
    public List<TwoType> getOneTwoTypeByOneType(String oneTypeId) {
        return oneTwoTypeMapper.getOneTwoTypeByOneType(oneTypeId);
    }

    @Override
    public List<TwoTypeDTO> getTwoPageByDTO(TwoTypeDTO twoTypeDTO) {
        return oneTwoTypeMapper.getTwoPageByDTO(twoTypeDTO);
    }

    @Override
    public void saveOneTwoType(OneTwoType oneTwoType) {
        oneTwoTypeMapper.insert(oneTwoType);
    }

    @Override
    public void deleteOneTwoType(Integer id) {

        OneTwoType oneTwoType = new OneTwoType();

        oneTwoType.setId(id);
        oneTwoType.setDelDateTime(new Date());

        oneTwoTypeMapper.updateOneTwoTypeById(oneTwoType);
    }
}
